package com.gitee.huxing.course.conc.conc01;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Description:
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.course.conc.cono01
 * @ClassName: ThreadMain
 * @Author: huxing
 * @DateTime: 2021-08-20 上午10:17
 */
public class ThreadMain {

    public static void main(String[] args) {

        ThreadA threadA = new ThreadA();
        threadA.start();
        System.out.println("这是主线程: ");

        ThreadB threadB = new ThreadB();
        new Thread(threadB).start();
        System.out.println("这是主线程: ");

        ThreadC threadC = new ThreadC();
        FutureTask<String> futureTask = new FutureTask<>(threadC);
        new Thread(futureTask).start();
        System.out.println("这是主线程:begin!");
        try {
            System.out.println("得到返回的结果: " + futureTask.get());
        } catch (InterruptedException ex){
            ex.printStackTrace();
        } catch (ExecutionException ex){
            ex.printStackTrace();
        }
    }
}
